import {
  C0LUMNS,
  DELIVERY_ORDER_C0LUMNS,
  RECEIVE_C0LUMNS,
  INVENTORY_COORDINATION,
  RECEIVE_COORDINATION,
  SHIPPING_INFORMATION,
  SURGICAL_TOOLS
} from './index.const';
import ElEditable from '@components/el-editable';
import {
  IndexService
} from './index.service';
import step from '~/modules/step';
const indexService = new IndexService();
export default {
  components: {
    ElEditable,
    step
  },
  inject: ['apiMMallWeb'],
  data() {
    return {
      currentPage: 1,
      pageSize: 20,
      receivCurrentPage: 1,
      receivPageSize: 20,
      receivData: {},
      toolsCurrentPage: 1,
      toolsPageSize: 20,
      tableLoading: false,
      payload: {},
      consigneeInfo: {},
      dialogVisible: false,
      C0LUMNS,
      RECEIVE_COORDINATION, //收货信息表头
      RECEIVE_C0LUMNS, //收货详情表头
      DELIVERY_ORDER_C0LUMNS, //出库单表头
      SHIPPING_INFORMATION, //配送信息表头
      SURGICAL_TOOLS, //手术工具表头
      orderDetail: {},
      stepData: [],
      orderId: '',
      busModel: 1,
      activeName: 'first',
      order_tab: [{
        orderId: '5087560',
        orderDate: '2020-3-16',
        productId: 'MTA02A',
        pruductName: '11G骨导针',
        pcId: '11256450',
        indate: '2020-04-01',
        count: '7',
        factoryName: '国科恒远(北京)医疗有限公司'
      }]
    };
  },
  async created() {
    this.orderId = this.$route.query.id;
    //获取步骤条数据
    this.getStepList()
    //根据id获取列表详情
    const detail = await this.apiMMallWeb.OrderDetailOrderV1ApiPOST({
      query: {
        orderId: this.orderId,
        page: 0,
        pageSize: 20
      }
    });
    indexService.getTransportName(detail);
    this.orderDetail = detail;
    //获取附加信息
    const data = await this.apiMMallWeb.AppendRelateOrderV1ApiPOST({
      form: {
        busModel: this.busModel,
        productLineCode: this.orderDetail.productLineCode
      }
    });
    this.appendRelateOrder = data;
    //库存配位
    const res = await this.apiMMallWeb.PageListStockBatchOrderV1ApiPOST({
      query: {
        orderId: this.orderId,
        page: 0,
        pageSize: 20
      }
    });
    this.order_tab[0].tabData = res.content;
    //收货人信息
    const consigneeInfo = await this.apiMMallWeb.OrderReceiverOrderV1ApiPOST({
      query: {
        orderId: this.orderId,
        page: 0,
        pageSize: 20
      }
    });
    this.consigneeInfo = consigneeInfo;

  },
  methods: {
    getStepList() {
      this.stepData = [{
          name: '订单已提交',
          time: '2020-11-12 12:23:31',
          status: 0,
          next: '',
        }, {
          name: '审核通过',
          time: '2020-11-12 12:23:31',
          status: 1,
          next: '待支付',
        }, {
          name: '已支付',
          time: '',
          status: 0,
          next: '',
        }, {
          name: '已出库',
          time: '',
          status: 0,
          next: '',
        }, {
          name: '已出库',
          time: '',
          status: 0,
          next: '',
        },
        {
          name: '已出库',
          time: '',
          status: 0,
          next: '',
        }
      ]
    },
    //添加高亮
    tableRowClassName({
      row
    }) {
      if (row.orderCount > row.inventoryCount) {
        return 'bgHeight';
      }
    },
    //订单详情采购产品分页列表
    async getList() {
      this.tableLoading = true
      const payload = await this.apiMMallWeb.PageListOrderDetailProductOrderV1ApiPOST({
        query: {
          orderDetailId: this.orderDetail.orderDetailId,
          page: this.currentPage,
          pageSize: pageSize
        }
      });
      this.payload = payload;
      this.tableLoading = false
    },
    //获取手术工具列表
    getToolsList() {

    },
    //订单详情采购产品分页列表分页器
    reloadTools(val) {
      this.toolsCurrentPage = val.number
      this.toolsPageSize = val.size
      this.getToolsList()
    },
    //订单详情采购产品分页列表分页器
    reloadProductData(val) {
      this.currentPage = val.number
      this.pageSize = val.size
      this.getList()
    },
    //收货信息-详情列表分页器r
    reloadReceiv(val) {
      this.receivCurrentPage = val.number
      this.receivPageSize = val.size
      this.getReceivList()
    },
    //收货信息-详情列表
    getReceivList() {

    },
    showLog() {
      this.dialogVisible = true;
    },
    //底部tab切换调用不同接口
    handleClick(tab, event) {
      console.log(tab, event);
    },
  }
};